<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv=X-UA-Compatible content="IE=edge,chrome=1">
    <meta content=always name=referrer>
    <link rel="stylesheet" type="text/css" href="__STATIC__/css/base.css">
    <script src="__STATIC__/js/jquery-1.8.2.js"></script>
    <title>分类--搜索</title>
</head>
{include file="public/search_head" /}
    <div class="center">
        <h4>热门搜索</h4>
        <ul class="hot">
            {volist name='hot_search' id='v'}
            <li><a href="javascript:hot_search('{$v}');">{$v}</a></li>
            {/volist}
        </ul>
        <h4>历史搜索</h4>
        <div  class="history">
            <ul id="history_search">
                {volist name='history' id='v'}
                <li><a href="{$v.url}"><img src="__STATIC__/img_user/fl-sousuotubiao.png"><span>{$v.keyword}</span></a></li>
                {/volist}
            </ul>
            <p><a href="javascript:clear();">清空搜索历史</a></p>
        </div>
    </div>
</div>
<script src="__STATIC__/js/layer_mobile/layer.js"></script>
<script>
    //热门搜索
    function hot_search(text){
        sessionStorage.setItem('search_back_url',window.location.href);
        window.location.href = "{:url('mobile/user_category/search_goods')}?search="+text;
    }
    //跳转搜索结果展示页
    function search_head(){
        var result = $('#result').val(),
            search = $("#keyword").val();

        if (search == ''){
            layer.open({content:'搜索内容不能为空',skin:'msg',time:2});
            return false;
        }
        sessionStorage.setItem('search_back_url',window.location.href);
        if (result == 1){  //商品
            window.location.href = "{:url('mobile/user_category/search_goods')}?search="+search;
        }else{  //店铺
            window.location.href = "{:url('mobile/user_category/search_shop')}?type=2&search="+search;
        }
    }

    keyword.onkeydown = function(e){
        if (e.keyCode==13){
            var result = $('#result').val(),
                    search = $("#keyword").val();

            if (search == ''){
                layer.open({content:'搜索内容不能为空',skin:'msg',time:2});
                return false;
            }
            sessionStorage.setItem('search_back_url',window.location.href);
            document.activeElement.blur();
            if (result == 1){  //商品
                window.location.href = "{:url('mobile/user_category/search_goods')}?search="+search;
            }else{  //店铺
                window.location.href = "{:url('mobile/user_category/search_shop')}?type=2&search="+search;
            }
        }
    };

    function change(id){
        if (id == 1){
            $('#search').text('商品');
            $('#result').val(1);
            $('#UL').css('display','none');
            $('.ys').eq(0).addClass('selected');
            $('.ys').eq(1).removeClass('selected');
        }else{
            $('#result').val(2);
            $('#search').text('店铺');
            $('#UL').css('display','none');
            $('.ys').eq(1).addClass('selected');
            $('.ys').eq(0).removeClass('selected');
        }
    }
    function toggle_type(){
        $('#UL').toggle();
    }
    function clear(){
        $.post('',function(t){
            $('#history_search').text('');
            layer.open({content:t.message,skin:'msg',time:2});
        })
    }
</script>
</body>
</html>